Skip to content

feat(cli): run test sessions via the async v1 scheduling API [RED-680] [show] - #1420

Merged
sorccu merged 1 commit into
mainfrom
simo/red-680-fail-fast-on-scheduling-failure
Jul 27, 2026
Merged

feat(cli): run test sessions via the async v1 scheduling API [RED-680] [show]#1420
sorccu merged 1 commit into
mainfrom
simo/red-680-fail-fast-on-scheduling-failure

Conversation

@sorccu

@sorccu sorccu commented Jul 24, 2026

Copy link
Copy Markdown
Member

Linear: RED-680

What

checkly test and checkly trigger --record now run test sessions through the new asynchronous scheduling API instead of the legacy synchronous endpoint:

  • TestSessions.run() calls POST /v1/test-sessions/run. The 202 arrives as soon as the session is validated and persisted — the backend dispatches the checks in the background — and additionally carries a schedulingId identifying the dispatch operation.
  • New REST helpers cover the scheduling status endpoints: getSchedulingCompletion and pollSchedulingUntilComplete (30s long-poll on GET /v1/test-sessions/scheduling/{schedulingId}/completion, 408 → retry).

Keeping dispatch failures visible

With the synchronous endpoint, a dispatch failure (bad snippet, missing private location, queue trouble) surfaced in the HTTP response itself. Under the async contract the 202 predates dispatch, so without anything else a background dispatch failure would mean: 202, then no results, until the per-check timeout expires with a generic message. To keep the old failure visibility:

  • While results stream over MQTT, a watchScheduling promise polls the scheduling operation and rejects with TestSessionSchedulingFailedError (code: SCHEDULING_ERROR | ABANDONED) the moment dispatch fails — including when the scheduling worker dies and the backend reaper reclaims the operation. The run exits non-zero within seconds, with the real error.
  • --detach awaits scheduling success before emitting DETACH, so detach mode cannot exit zero for a session that was never dispatched.
  • Poll infrastructure errors are best-effort: they never fail an otherwise healthy run.

Behavior notes (accepted)

  • An ERROR can now surface mid-stream (previously only at start or timeout).
  • --detach gains a few seconds of latency (one completion poll round-trip).
  • The 408 retry loop is deliberately unbackoffed, matching the deploy completion polling convention.

Backend dependency

Requires the new v1 test-session scheduling endpoints on the Checkly backend (internal change, tracked under RED-680; in the merge queue at the time of writing). Blocked from release — not from merge — until that backend change is live in production: the CLI calls v1 unconditionally, with no fallback to the legacy endpoint (deliberate decision). Merging is safe; releasing before the backend is deployed would break checkly test for everyone on the new version.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HFcrNm7uzzkD1p87Nf9AhP

@sorccu sorccu changed the title [RED-680] fix(backend): async test-session scheduling — /next/test-sessions/run 504 for 1200+ checks (+ POST /v1/test-sessions/run with completion polling) feat(cli): fail fast when async test-session dispatch fails [RED-680] Jul 24, 2026
@sorccu sorccu changed the title feat(cli): fail fast when async test-session dispatch fails [RED-680] feat(cli): run test sessions via the async v1 scheduling API [RED-680] Jul 27, 2026
@sorccu

sorccu commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

The failing retry-project > Should execute retries e2e is not caused by this PR: it fails identically on every branch (including ones using the legacy endpoint, e.g. #1419) since 2026-07-23, because of a regression in the production results pipeline that silently disables ad-hoc retries. Tracked internally as TREE-1094. The rest of the e2e suite passes on this branch.

checkly test now runs sessions via POST /v1/test-sessions/run, which
dispatches the check runs in the background after the 202. The CLI watches
the returned scheduling operation (long-poll with 408 retries, aborted once
the run settles) and fails the run immediately with the server's error when
dispatch fails — previously a server-side dispatch failure produced no MQTT
results and the CLI hung for the full per-check timeout (600s, or 1200s for
Playwright) before printing a generic timeout.

In --detach mode the CLI confirms dispatch reached a terminal state before
detaching, so a dispatch failure still exits non-zero like the synchronous
endpoint did.

Requires the backend scheduling endpoints (checkly/monorepo#2795) — do not
release before they are live in production.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFcrNm7uzzkD1p87Nf9AhP
@sorccu
sorccu force-pushed the simo/red-680-fail-fast-on-scheduling-failure branch from 90db48b to 5f3aa74 Compare July 27, 2026 12:05
@sorccu sorccu changed the title feat(cli): run test sessions via the async v1 scheduling API [RED-680] feat(cli): run test sessions via the async v1 scheduling API [RED-680] [show] Jul 27, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: ship/show PR from a same-repo branch.

@sorccu
sorccu merged commit 094708b into main Jul 27, 2026
16 checks passed
@sorccu
sorccu deleted the simo/red-680-fail-fast-on-scheduling-failure branch July 27, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant